import fetch from 'common/src/utils/fetch';

function assessRulesSettingAllList(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/assessRulesSettingAllList',
        method: 'post',
        data
    });
}

function assessTimeSettingList(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/assessTimeSettingList',
        method: 'post',
        data
    });
}

function insertTimeSetting(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/insertTimeSetting ',
        method: 'post',
        data
    });
}

function updateTimeSetting(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/updateTimeSetting',
        method: 'post',
        data
    });
}

function deleteTimeSetting(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/deleteTimeSetting ',
        method: 'delete',
        data
    });
}

function getWhiteListCourse(params) {
    return fetch({
        url: '/api/cultureservice/bclCourses/page' + getParams(params),
        method: 'get'
    });
}

function getParams(params) {
    var paramsData = [];
    for (const key in params) {
        params[key] &&
            paramsData.push(
                key + '=' + params[key]
            );
    }
    if (paramsData.length)
        return '?' + paramsData.join('&');
    else
        return '';
}

const timeSetApi = {
    'assessRulesSettingAllList': assessRulesSettingAllList,
    'assessTimeSettingList': assessTimeSettingList,
    'insertTimeSetting': insertTimeSetting,
    'updateTimeSetting': updateTimeSetting,
    'deleteTimeSetting': deleteTimeSetting,
    'getWhiteListCourse': getWhiteListCourse,
}

export default timeSetApi;